﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wq.Application;
using Wq.Framework;
using Wq.Framework.Base.Admin;
using Wq.ManagerService.Models;
using Wq.Model;

namespace Wq.Manager.API
{
    /// <summary>
    /// 系统配置 
    /// </summary>
    [Route("admin")]
    public class SettingsController : ManagerBaseController
    {
        private readonly SettingsApplication settingsApplication;
        /// <summary>
        /// 系统配置
        /// </summary>
        /// <param name="settingsApplication"></param>

        public SettingsController(SettingsApplication settingsApplication) => this.settingsApplication = settingsApplication;

        /// <summary>
        /// 获取站点配置
        /// </summary>
        /// <returns></returns>

        [HttpGet("setting")]
        public IActionResult GetSetting() => SuccessResult(settingsApplication.GetSetting());

        /// <summary>
        /// 保存配置
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        [HttpPost("setting")]
        public IActionResult SaveSetting(SiteSetting setting)
        {
            settingsApplication.SetSetting(setting);
            return SuccessResult();
        }
    }
}
